
#ifndef LILY_H
#define LILY_H

#ifdef __cplusplus
extern "C"
{
#endif

	// implement this first
	extern void (*_li_Delay)(uint32_t ms);
	extern uint32_t (*_li_millis)();
	// builtin helpful fields, for debugging
	extern const char *__li_error_msg,*__li_error_msg2;
	extern const char *__li_error_loc;

	extern float __Nanf;
#define li_error(msg, code)        \
	{                              \
		__li_error_loc = __FILE__; \
		__li_error_msg = msg;      \
		return code;               \
	}

#define assert_not_empty(var)                     \
	{                                             \
		if (var == NULL)                          \
		{                                         \
			li_error("assign failed", -__LINE__); \
		}                                         \
	}
#define assert_true(exp)                          \
	{                                             \
		if (!(exp))                               \
		{                                         \
			li_error("assert failed", -__LINE__); \
		}                                         \
	}
#define assert_msg(exp, msg)          \
	{                                 \
		if (!(exp))                   \
		{                             \
			li_error(msg, -__LINE__); \
		}                             \
	}

	void lily_out(const char *msg);
	void lily_outf(const char *fmt, ...);

	// extern interface
	void lily_in(char c);
	void lily_init(void);
	Pipe lily_pipe_io_setup(Pipe pipe_to_std_out);
	Pipe lily_get_current_pipe();
	int lily_redirect_output(Pipe newLine);

#ifdef __cplusplus
}
#endif

#endif
